﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AirLinq.Providers.Sql {
	public class SqlBinaryLogicalExpression : SqlLogicalExpression{
		private readonly SqlLogicalExpression _left;
		private readonly SqlLogicalExpression _right;
		private readonly SqlNodeType _nodeType;

		public SqlBinaryLogicalExpression(SqlLogicalExpression left, SqlNodeType nodeType,  SqlLogicalExpression right) {
			if (left == null) {
				throw new ArgumentNullException("left");
			}
			if (right == null) {
				throw new ArgumentNullException("right");
			}
			if (nodeType != SqlNodeType.And
				&& nodeType != SqlNodeType.Or) {
				throw new ArithmeticException("operation must be 'and' or 'or'");
			}
			_left = left;
			_right = right;
			_nodeType = nodeType;
		}
		public SqlLogicalExpression Left {
			get {
				return _left;
			}
		}
		public SqlLogicalExpression Right {
			get {
				return _right;
			}
		}
		public override bool IsNotInjectionable {
			get {
				return false;
			}
		}
		public override SqlNodeType NodeType{
			get {
				return _nodeType;
			}
		}
	}
}
